# Maintainer: Celeste <cielesti@protonmail.com>
maintainer="Celeste <cielesti@protonmail.com>"
pkgname=slidge-matridge
pkgver=0.1.0
pkgrel=0
pkgdesc="Feature-rich Matrix to XMPP puppeteering gateway"
url="https://slidge.im/matridge/"
# loongarch64: test failure - aiohttp/client.py: no running event loop
arch="noarch !loongarch64"
license="AGPL-3.0-or-later"
depends="
	py3-async-lru
	py3-atomicwrites
	py3-beautifulsoup4
	py3-cachetools
	py3-matrix-nio
	py3-olm
	py3-peewee
	py3-slidge-style-parser
	slidge
	"
makedepends="
	py3-gpep517
	py3-poetry-core
	"
checkdepends="
	py3-pytest
	py3-pytest-asyncio
	py3-xmldiff
	"
pkgusers="slidge"
pkggroups="slidge"
subpackages="$pkgname-openrc $pkgname-pyc"
source="$pkgname-$pkgver.tar.gz::https://git.sr.ht/~nicoco/matridge/archive/v$pkgver.tar.gz
	matridge.conf
	"
builddir="$srcdir/matridge-v$pkgver"

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl
	.testenv/bin/python3 -m pytest
}

package() {
	python3 -m installer -d "$pkgdir" .dist/*.whl

	install -dm750 -o slidge -g slidge \
		"$pkgdir"/etc/slidge
	install -Dm640 -o slidge -g slidge \
		"$srcdir"/matridge.conf \
		-t "$pkgdir"/etc/slidge/

	install -dm755 "$pkgdir"/etc/init.d
	ln -s slidge "$pkgdir"/etc/init.d/slidge.matridge
}

sha512sums="
4cc73a961c1013aa0ff40471044f8f0a979ed18fc95e454f9193812ed92e2de72b4cb77dc7e607c4c02a981166bd23ab509f6fe9b956574d063600820161c2c2  slidge-matridge-0.1.0.tar.gz
e5f5c7f1f0ad2c96d04f0f2eb8eaea856db99f0cab92a05b080bce83a2fea4848a0573ff5e0490dee92c5d6d66dd1201f8ff2ab5c5717ae11f2ff7a193ac8a2d  matridge.conf
"
